package com.bc.bczbweb.controller.Ajax;

import com.baidu.disconf.client.utils.StringUtil;
import com.bc.bcapi.service.T_SequenceService;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Project_typeService;
import com.bc.bcmodel.domain.T_Project_typeModel;
import com.bc.commonentity.enums.SeqNameEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.POST;
import java.math.BigInteger;

@RestController
@RequestMapping("ajax/t_project_type")
public class AjaxT_Project_typeController {
    @Autowired
    T_Project_typeService t_Project_typeService;

    @Autowired
    T_SequenceService t_SequenceService;

    @POST
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public JsonResult add(T_Project_typeModel req) {
        JsonResult js = new JsonResult();
        if (!StringUtils.isEmpty(req.getTid())) {
            t_Project_typeService.update(req);
        } else {
            req.setTid(t_SequenceService.genSequence(SeqNameEnum.PROJECT_TYPE));
            t_Project_typeService.insert(req);
        }
        return js;
    }

    @RequestMapping("del")
    public JsonResult del(String tid) {
        JsonResult js = new JsonResult();
        T_Project_typeModel model = new T_Project_typeModel();
        model.setTid(tid);
        model.setIsdel(1);
        t_Project_typeService.update(model);
        return js;
    }
}